<?php include $this->admin_tpl('meta');?>
<title>批量更新URL - YzmCMS内容管理系统</title>
<style>
	.table th{font-weight:normal;}
	.select{border:solid 1px #999;font-size:12px}
</style>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 批量更新URL <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
  <div class="explain light"> 
     <p><span class="yzm-iconfont yzm-iconshuoming"></span>仅当修改了“网站域名”或修改了“前台URL模式”时，才需批量更新，其他情况，无需更新 .</p>
     <p><span class="yzm-iconfont yzm-iconshuoming"></span>前台URL模式修改：系统管理 > 系统设置 > 附加设置 > 前台URL模式.</p>
  </div>
	<div class="pd-5 mt-10">
	<table class="table table-bg">

	<form action="<?php echo U('change_model');?>" method="post" id="myform">
	    <input type="hidden" name="dosubmit" value="1"> 
		<thead height="50" >
			<tr>
				<th style="text-align:center;font-size:14px"  width="150">按照模型更新</th>
				<th style="text-align:center;font-size:14px" width="386">选择栏目范围</th>
				<th style="font-size:14px" >选择操作内容</th>
			</tr>
		</thead>
		<tbody  height="300">
			<tr> 
				<td rowspan="2" style="text-align:center">
				<select name="modelid" size="2" class="select" style="height:250px;width:140px;" onchange="change_model()">
					<option value='0' <?php if(!$modelid) echo 'selected';?>>≡ 所有模型 ≡</option>
					<?php
					 foreach($modelinfo as $val){
						$str = $modelid==$val['modelid'] ? 'selected' : '';
						echo '<option value="'.$val['modelid'].'" '.$str.'>'.$val['name'].'</option>';
					 }
					?>
				</select>
				</td>
				<td rowspan="2" style="text-align:center">
					<?php echo $select;?>
				</td>
				<td style="font-size:14px">更新栏目URL &nbsp;&nbsp;<input type="button" value="开始更新" class="btn btn-primary radius" onclick="yzm_ajax('<?php echo U('update_category_url')?>')"></td>
			</tr>
			<tr> 
				<td style="font-size:14px">更新内容URL &nbsp;&nbsp;<input type="button" value="开始更新" class="btn btn-primary radius" onclick="yzm_ajax('<?php echo U('update_content_url')?>')"></td>
			</tr>
		</tbody>
	</form>
	</table>

	</div>
</div>
<?php include $this->admin_tpl('footer');?>

<script type="text/javascript">
	$("#select option:first").prop("selected", 'selected');  

	function yzm_ajax(url) {
		layer.msg('<span id="yzm_message">开始请求服务器……</span>', {icon:16, shade:0.21, time:false});
		$.ajax({
	        type: 'POST',
	        url: url, 
	        data: $("#myform").serialize(),
		    dataType: "json", 
	        success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1,time:1500});
			    }else if(msg.status == 2){
			    	$("#yzm_message").html(msg.message);
					yzm_dorequest(url, msg.autoid, msg.total, msg.page);
				}else{
					layer.alert(msg.message, {icon:2});
				}
	        }
	    })
	}

	function yzm_dorequest(url, autoid, total, page) {
		$.ajax({
	        type: 'POST',
	        url: url, 
	        data: {"autoid":autoid, "total":total, "page":page, "yzm_csrf_token":yzm_csrf_token},
		    dataType: "json", 
	        success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1,time:1500});
			    }else if(msg.status == 2){
			    	$("#yzm_message").html(msg.message);
					yzm_dorequest(url, msg.autoid, msg.total, msg.page);
				}else{
					layer.alert(msg.message, {icon:2});
				}
	        }
	    })
	}

	function change_model() {
		document.getElementById('myform').submit();
	}
</script>
</body>
</html>